﻿using System;

namespace Angle.Krill.Utils
{
    internal class CodeHelper
    {
        /// <summary>
        /// 加密
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static string Base64Encrypt(string text)
        {
            byte[] data = System.Text.Encoding.UTF8.GetBytes(text);
            string base64String = Convert.ToBase64String(data);

            return base64String;
        }
        /// <summary>
        /// 解密
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static string Base64Decrypt(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return string.Empty;
            }
            byte[] data = Convert.FromBase64String(text);
            string decodedString = System.Text.Encoding.UTF8.GetString(data);

            return decodedString;
        }
    }
}
